import { defineFakeRoute } from "vite-plugin-fake-server/client";

export default defineFakeRoute([
  //  计划理财
  {
    url: "/plan",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-21 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          plan_id: 16,
          plan_name: "易方达蓝筹投资基金",
          plan_amount: -1000,
          plain_start_time: "2023-11-02 00:00:00",
          end_plain_cycle: "10",
          real_cycle: 0,
          real_month: 0,
          plain_end_time: "",
          is_notice: 1,
          plan_type: 1,
          plan_status: 2,
          cycle_type: 1,
          nick_name: "宋修轩",
          category_name: "金融投资",
          property_name: "",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          third_code: "005827",
          portion_amount: 22
        },
        {
          createTime: "2023-04-20 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          plan_id: 17,
          plan_name: "招商中证白酒指数基金",
          plan_amount: -200,
          plain_start_time: "2023-11-03 00:00:00",
          end_plain_cycle: "5",
          real_cycle: 0,
          real_month: 0,
          plain_end_time: "",
          is_notice: 2,
          plan_type: 1,
          plan_status: 2,
          cycle_type: 1,
          nick_name: "宋修轩",
          category_name: "金融投资",
          property_name: "",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          third_code: "161725",
          portion_amount: 32
        },
        {
          createTime: "2023-04-15 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          plan_id: 12,
          plan_name: "美丽家园物业费",
          plan_amount: -1000,
          plain_start_time: "2023-11-03 00:00:00",
          end_plain_cycle: "0",
          real_cycle: 0,
          real_month: 0,
          plain_end_time: "",
          is_notice: 1,
          plan_type: 1,
          plan_status: 2,
          cycle_type: 2,
          nick_name: "宋修轩",
          category_name: "住房",
          property_name: "美丽家园",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          third_code: "",
          portion_amount: 0
        },
        {
          createTime: "2023-04-14 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          plan_id: 11,
          plan_name: "迈腾汽车保养费",
          plan_amount: -900,
          plain_start_time: "2023-11-03 00:00:00",
          end_plain_cycle: "1",
          real_cycle: 0,
          real_month: 0,
          plain_end_time: "",
          is_notice: 2,
          plan_type: 1,
          plan_status: 2,
          cycle_type: 2,
          nick_name: "宋修轩",
          category_name: "金融投资",
          property_name: "",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          third_code: "",
          portion_amount: 0
        },
        {
          createTime: "2023-04-10 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          plan_id: 11,
          plan_name: "宋修轩工资",
          plan_amount: 10000,
          plain_start_time: "2023-11-03 00:00:00",
          end_plain_cycle: "0",
          real_cycle: 0,
          real_month: 0,
          plain_end_time: "",
          is_notice: 2,
          plan_type: 2,
          plan_status: 2,
          cycle_type: 1,
          nick_name: "宋修轩",
          category_name: "工资",
          property_name: "",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          third_code: "",
          portion_amount: 0
        }
      ];
      list = list.filter(item => item.plan_name.includes(body?.plan_name));
      if (body.user_id) {
        list = list.filter(item => item.user_id == body?.user_id);
      }
      if (body.family_id) {
        list = list.filter(item => item.family_id == body?.family_id);
      }
      if (body.category_id) {
        list = list.filter(item => item.category_id == body?.category_id);
      }
      if (body.property_id) {
        list = list.filter(item => item.property_id == body?.property_id);
      }

      if (body.third_code) {
        list = list.filter(item => item.third_code == body?.third_code);
      }
      if (body.plan_type) {
        list = list.filter(item => item.plan_type == body?.plan_type);
      }
      if (body.plan_status) {
        list = list.filter(item => item.plan_status == body?.plan_status);
      }
      if (body.cycle_type) {
        list = list.filter(item => item.cycle_type == body?.cycle_type);
      }
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  收支账单
  {
    url: "/bills",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-01 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          blog_id: 1,
          blog_month: 202302,
          plan_id: 12,
          nick_name: "宋修轩",
          category_name: "住房",
          property_name: "美丽家园",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          bills_type: 1,
          amount: -1000
        },
        {
          createTime: "2023-04-01 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          blog_id: 2,
          blog_month: 202303,
          plan_id: 13,
          nick_name: "宋修轩",
          category_name: "生活日用",
          property_name: "迈腾汽车",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          bills_type: 1,
          amount: -900
        },
        {
          createTime: "2023-04-24 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          blog_id: 3,
          blog_month: 202303,
          plan_id: 14,
          nick_name: "宋修轩",
          category_name: "工资",
          property_name: "",
          family_name: "宋氏家庭",
          user_id: 22,
          family_id: 22,
          category_id: 455,
          property_id: 3222,
          bills_type: 2,
          amount: 10000
        }
      ];
      if (body.user_id) {
        list = list.filter(item => item.user_id == body?.user_id);
      }
      if (body.family_id) {
        list = list.filter(item => item.family_id == body?.family_id);
      }
      if (body.category_id) {
        list = list.filter(item => item.category_id == body?.category_id);
      }
      if (body.property_id) {
        list = list.filter(item => item.property_id == body?.property_id);
      }

      if (body.blog_month) {
        list = list.filter(item => item.blog_month == body?.blog_month);
      }

      if (body.plan_id) {
        list = list.filter(item => item.plan_id == body?.plan_id);
      }
      if (body.bills_type) {
        list = list.filter(item => item.bills_type == body?.bills_type);
      }
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  理财账单
  {
    url: "/bills/manage_money",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-01 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          blog_id: 11,
          third_code: "005827",
          portion_amount: 22,
          blog_month: 202302,
          plan_id: 16,
          nick_name: "宋修轩",
          category_name: "金融投资",
          user_id: 222,
          category_id: 32,
          bills_type: 1,
          amount: -420
        },
        {
          createTime: "2023-04-01 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          blog_id: 12,
          third_code: "161725",
          portion_amount: 32,
          blog_month: 202303,
          plan_id: 17,
          nick_name: "宋修轩",
          category_name: "金融投资",
          user_id: 222,
          category_id: 32,
          bills_type: 2,
          amount: 120
        }
      ];
      if (body.user_id) {
        list = list.filter(item => item.user_id == body?.user_id);
      }
      if (body.category_id) {
        list = list.filter(item => item.category_id == body?.category_id);
      }

      list = list.filter(item => item.third_code.includes(body?.third_code));
      if (body.blog_month) {
        list = list.filter(item => item.blog_month == body?.blog_month);
      }
      if (body.plan_id) {
        list = list.filter(item => item.plan_id == body?.plan_id);
      }
      if (body.bills_type) {
        list = list.filter(item => item.bills_type == body?.bills_type);
      }
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  资产账单
  {
    url: "/bills/property",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          blog_month: 202302,
          property_name: "美丽家园",
          family_name: "宋氏家庭",
          family_id: 222,
          property_id: 33,
          amount: -2700
        },
        {
          blog_month: 202303,
          property_name: "迈腾汽车",
          family_name: "宋氏家庭",
          family_id: 222,
          property_id: 33,
          amount: -3200
        },
        {
          blog_month: 202305,
          property_name: "知识之府",
          family_name: "赵氏家庭",
          family_id: 222,
          property_id: 33,
          amount: -1200
        }
      ];

      if (body.family_id) {
        list = list.filter(item => item.family_id == body?.family_id);
      }
      if (body.property_id) {
        list = list.filter(item => item.property_id == body?.property_id);
      }
      if (body.blog_month) {
        list = list.filter(item => item.blog_month == body?.blog_month);
      }
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  家庭财产
  {
    url: "/property",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-11 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          property_id: 1,
          property_name: "美丽家园",
          family_name: "宋氏家庭",
          family_id: 22,
          property_remark: "美丽家园1-2-1202，109平米"
        },
        {
          createTime: "2023-04-12 00:00:00",
          updateTime: "2023-05-01 00:00:00",
          property_id: 2,
          property_name: "迈腾汽车",
          family_name: "宋氏家庭",
          family_id: 22,
          property_remark: "汽油车，使用95号汽油"
        },
        {
          createTime: "2023-04-13 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          property_id: 1,
          property_name: "知识之府",
          family_name: "赵氏家庭",
          family_id: 22,
          property_remark: "知识之府5-1-0708，89平米"
        }
      ];
      list = list.filter(item =>
        item.property_name.includes(body?.property_name)
      );
      if (body.family_id) {
        list = list.filter(item => item.family_id == body?.family_id);
      }
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  家庭
  {
    url: "/family",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-11 00:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          family_id: 1,
          family_name: "宋氏家庭",
          family_remark: "我们是一个幸福美满的四口之家，位于繁华的城市中心。"
        },
        {
          createTime: "2023-04-21 00:00:00",
          updateTime: "2023-05-01 00:00:00",
          family_id: 2,
          family_name: "赵氏家庭",
          family_remark: "我们是一个温馨的三口之家，位于一个美丽的海滨城市。"
        }
      ];
      list = list.filter(item => item.family_name.includes(body?.family_name));
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  },
  //  分类
  {
    url: "/category",
    method: "post",
    response: ({ body }) => {
      let list = [
        {
          createTime: "2023-04-01 08:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          category_id: 10,
          category_name: "工资",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 10,
          category_type: 2 // 状态 1 启用 0 停用
        },
        {
          createTime: "2023-04-01 08:00:00", // 时间戳（毫秒ms）
          updateTime: "2023-05-01 00:00:00",
          category_id: 1,
          category_name: "休闲娱乐",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 9,
          category_type: 2 // 状态 1 启用 0 停用
        },
        {
          createTime: "2023-04-02 11:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 2,
          category_name: "购物",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 8,
          category_type: 2
        },
        {
          createTime: "2023-04-03 00:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 3,
          category_name: "生活日用",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 7,
          category_type: 2
        },
        {
          createTime: "2023-04-01 12:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 4,
          category_name: "金融投资",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 6,
          category_type: 2
        },
        {
          createTime: "2023-04-08 08:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 5,
          category_name: "住房",
          family_name: "宋氏家庭",
          family_id: 22,
          weight: 5,
          category_type: 2
        },
        {
          createTime: "2023-04-11 08:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 6,
          category_name: "宠物",
          family_name: "赵氏家庭",
          family_id: 221,
          weight: 4,
          category_type: 2
        },
        {
          createTime: "2023-04-12 08:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 7,
          category_name: "养娃",
          family_name: "赵氏家庭",
          family_id: 221,
          weight: 3,
          category_type: 2
        },
        {
          createTime: "2023-04-13 08:00:00",
          updateTime: "2023-05-01 00:00:00",
          category_id: 8,
          category_name: "运动",
          family_name: "赵氏家庭",
          family_id: 221,
          weight: 2,
          category_type: 2
        }
      ];
      list = list.filter(item =>
        item.category_name.includes(body?.category_name)
      );
      if (body.family_id) {
        list = list.filter(item => item.family_id == body?.family_id);
      }
      list = list.filter(item =>
        String(item.category_type).includes(String(body?.category_type))
      );
      if (body.weight) list = list.filter(item => item.weight === body.weight);
      return {
        success: true,
        data: {
          list,
          total: list.length, // 总条目数
          pageSize: 10, // 每页显示条目个数
          currentPage: 1 // 当前页数
        }
      };
    }
  }
]);
